from django.db import models


class BookInfo(models.Model):
    name = models.CharField(max_length=20)
    pub_date = models.DateField(null=True)
    read_count = models.IntegerField(default=0)
    comment_count = models.IntegerField(default=0)
    is_delete = models.BooleanField(default=False)

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'book_info'
        verbose_name = '书籍管理'


class PeopleInfo(models.Model):
    GENDER_CHOICE = (
        (1, 'male'),
        (2, 'female')
    )
    name = models.CharField(max_length=10)
    gender = models.SmallIntegerField(choices=GENDER_CHOICE, default=1)
    desc = models.CharField(max_length=100, null=True)
    is_delete = models.BooleanField(default=False)

    book = models.ForeignKey(BookInfo, on_delete=models.CASCADE)

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'people_info'
        verbose_name = '人物管理'
